package com.jugheadzhou.streamkafkaconsumer.service;

import com.jugheadzhou.core.message.CustomProcessor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * 消息中转处理
 *
 * @author jugheadzhou
 * @date 2021-09-28
 */
@Slf4j
@Service
@EnableBinding(CustomProcessor.class)
public class TransformService {

    /**
     * 消息中间处理
     *
     * @param payload
     * @return
     */
    @ServiceActivator(inputChannel = CustomProcessor.INPUT, outputChannel = CustomProcessor.OUTPUT)
    public Object transform(Object payload) {
        log.info("开始消息中间处理：{}", payload);
        payload = "transform_" + payload.toString();
        log.info("消息中间处理结束：{}", payload);
        return payload;
    }

}
